<template>
  <dw-tree
    ref="categoryTreeRef"
    :getTreeUrl="getTreeUrl"
    :addTreeUrl="addTreeUrl"
    :editTreeUrl="editTreeUrl"
    :delTreeUrl="delTreeUrl"
    :treeProps="treeProps"
    @currentChange="currentNodeChange"
  ></dw-tree>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import type { IShellScriptCategory } from '../shell-script';

defineOptions({
  name: 'ShellScriptCategoryTree',
});
const categoryTreeRef = ref();
const getTreeUrl: string = '/admin-api/shell/script/category/list';
const addTreeUrl: string = '/admin-api/shell/script/category';
const editTreeUrl: string = '/admin-api/shell/script/category';
const delTreeUrl: string = '/admin-api/shell/script/category/{id}';
const treeProps = { label: 'categoryName', children: 'children', total: 'totalNum' };
const emits = defineEmits(['currentNodeChange']);
const currentNodeChange = (data: IShellScriptCategory, isEdit: boolean) => {
  emits('currentNodeChange', data, isEdit);
};
</script>
